package cn.alise.controller.admin;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.alise.controller.common.BaseController;
import cn.alise.qdp.model.role.RoleMenu;
import cn.alise.qdp.service.admin.RoleMenuService;
import cn.alise.util.JSONResult;


/**
 * 角色菜单管理控制器
 */
@Controller
@RequestMapping(value = "/roleMenu")
public class RoleMenuController extends BaseController {

	private static final long serialVersionUID = 3071751434812887748L;

	@Resource(name = "roleMenuService")
	private RoleMenuService roleMenuService;

	/**
	 * 角色菜单列表
	 */
	@RequestMapping(value = "/list")
	@ResponseBody
	public JSONResult list(HttpServletRequest request, Model model,
			RoleMenu roleMenu) {
		
		RoleMenu args = new RoleMenu();
		args.setRoleId(roleMenu.getRoleId());
		
		JSONResult result = new JSONResult();
        try {
        	List<Long> roleMenuList = this.roleMenuService.list(args);
            result.setStatus(1);
            result.setMessage("1");
            result.setData(roleMenuList);
            return result;
        } catch (RuntimeException e) {
            result.setStatus(0);
			result.setMessage("0");
			return result;
        }
	}
}